/*
 * @FilePath: /cpp_study/ch04/delete.cpp
 * @Description: using delete operator
 * @Author: dengrunting
 * @Date: 2021-12-21 14:28:40
 * @LastEditTime: 2021-12-21 14:43:33
 */
#include<iostream>
#include<cstring>

using namespace std;
char * getname(void);

int main(){
    char *name;
    name = getname();
    cout << name << " at " << (int *)name << "\n";
    delete []name;

    name = getname();
    cout << name << " at " << (int *)name << "\n";
    delete[] name;
    return 0;
}

char * getname(){
    char temp[80];
    cout << "Enter last name: ";
    cin >> temp;
    char *pn = new char[strlen(temp) + 1];
    strcpy(pn, temp);
    return pn;
}